﻿namespace IBTrader.Indicator.CandleStick
{
    using IBTrader.Charts;

    /// <summary>
    /// Accumulation Distribution Line is a volume-based indicator.
    /// </summary>
    class ADL : BaseVolume
    {
        public ADL(Worker worker, int interval = 60, int pinterval = 20) : base(worker, 1, interval, pinterval) { }
        protected override void Add(object _, Item item)
        {
            Prices.Add(Calc(item));
            //if (Prices.Init)
                OnHit(item.CloseLine, Prices.Sum);
        }
        internal static double Calc(Item item)
        {
            return NaN((((item.Close - item.Low) - (item.High - item.Close)) / (item.High - item.Low)) * item.Volume);
        }
    }
}
